package vn.com.tiz.core.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.KeyEvent;

public class DialogUtils {

	
	private DialogUtils() {
	}

	public static DialogInterface.OnKeyListener getUnsearchableDialogKeyListener() {
		return new DialogInterface.OnKeyListener() {
			public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
				if (keyCode == KeyEvent.KEYCODE_SEARCH) {
					return true;
				}

				return false;
			}
		};
	}

	/**
	 * 共通のダイアログビルダーを取得します。
	 * 
	 * @param context
	 * @return
	 */
	public static AlertDialog.Builder getDefaultAlertDialogBuilder(Context context) {
		return new AlertDialog.Builder(context)//
			.setOnKeyListener(getUnsearchableDialogKeyListener());
	}
}
